<extend name="common:base" />
<block name="content">
    <div id="header">
        <div class="header">
            <h1 class="tit">分类</h1>
        </div>
    </div>

    <div class="fl-a">
        <form action="" id="form">
            <input type="hidden" name="m" value="Home">
            <input type="hidden" name="c" value="Good">
            <input type="hidden" name="a" value="agentgoods">
            <input name="id" type="hidden" value="{$categories[0]['id']}" id="default">
            <div class="fl-search">
                <img src="{:C('__STATIC__')}{$theme}/Static/img/searchs.jpg">
                <input type="search" name="mName" class="fl-soushu" placeholder="请输入你要的商品" id="mName"/>
                <input type="hidden" name="model" value="1">
            </div>
        </form>
    </div>
    <div class="fl-b">
        <div class="fl-left">
            <div class="fl-rs">
                <ul>
                    <volist name="categories" id="categories">
                        <li onclick="ajax_get_cate('{$categories.id}');">{$categories['c_name']}</li>
                    </volist>
                </ul>
            </div>
        </div>
        <div class="fl-right" id="cate_list"></div>
    </div>
    <div class="footer">
        <ul class="footer-tab">
            <li>
                <a href="{:U('Index/index', array('shop_id'=>session('url_shop_id')))}">
                    <i class="foot_bg"></i>
                    <span>首页</span>
                </a>
            </li>
            <li>
                <a href="{:U('Good/cate', array('shop_id'=>session('url_shop_id')))}">
                    <i class="foot_bg1 foot-this"></i>
                    <span>分类</span>
                </a>
            </li>
            <li>
                <a href="{:U('GoodShopcart/shopcart', array('shop_id'=>session('url_shop_id')))}">
                    <i class="foot_bg2"></i>
                    <span>购物车</span>
                </a>
            </li>
            <li>
                <a href="{:U('Setting/personal', array('shop_id'=>session('url_shop_id')))}">
                    <i class="foot_bg3"></i>
                    <span>我的</span>
                </a>
            </li>
        </ul>
    </div>
    <script type="text/javascript">

        $(function() {

            //搜索功能
            $('#mName').blur(function() {
                var m_name = $(this).val();
                if (m_name != '') {
                    $('#form').submit();
                }
            });

        });

        var id = $('#default').val();
        ajax_get_cate(id);
        function ajax_get_cate( id) {
            $.ajax({
                type : "POST",
                url:"{:U('Good/ajax_cate_list')}",
                data : { pid :id},
                success: function(data){
                    $("#cate_list").html('');
                    $("#cate_list").append(data);
                    $("#default").val(id)
                }
            });
        }


    </script>
</block>
<block name="CSS">
    <link rel="stylesheet" href="{:C('__STATIC__')}{$theme}/Static/{:C('css')}/total.css" />
</block>
<block name="js">
    <script type="text/javascript">
        $(function() {
            $(".fl-rs li").click(function(){
                $(this).addClass("fl-ones").siblings().removeClass("fl-ones");
            })
        });
    </script>
</block>